// AlgoC.cpp : Main Entrance
//

#include "stdafx.h"
#include "Chapter1.h"

int _tmain(int argc, _TCHAR* argv[])
{
	FILE *fp=fopen("data.txt", "w");
	const int N=1000;
	const int M=100000;
	int p, q;
	srand(time(NULL));
	for ( int i=0; i<M; ++i ){
		p=rand()%N;
		while ( (q=rand()%N)==p);
		fprintf(fp, "%d %d\n", p, q);
	}
	//fclose(fp);
	//fp=fopen("data.txt", "r");
	freopen( "data.txt", "r", fp );
	monotools::CStopWatch sw;

	sw.Start();
	Connect1_1(fp, stdout);
	printf("1_1 time cost:%f\n", sw.NowInMicroF());

	fseek(fp, 0, SEEK_SET);
	sw.Start();
	Connect1_2(fp, stdout);
	printf("1_2 time cost:%f\n", sw.NowInMicroF());
	
	fseek(fp, 0, SEEK_SET);
	sw.Start();
	Connect1_3(fp, stdout);
	printf("1_3 time cost:%f\n", sw.NowInMicroF());

	fseek(fp, 0, SEEK_SET);
	sw.Start();
	Connect1_4(fp, stdout);
	printf("1_4 time cost:%f\n", sw.NowInMicroF());

	return 0;
}

